#include<stdio.h>
#include<stdlib.h>
#include<filesystem>
using namespace std;
typedef struct student{
    int id;
    char name[10];
    int age;
    struct student *next;
}*st;
st newNode(){
    st node=(st)malloc(sizeof(struct student));
    scanf("%d",&node->id);
    scanf("%s",node->name);
    scanf("%d",&node->age);
    node->next=NULL;
    return node;
}
st manageStu(st head){
    if(head==NULL){
        return newNode();
    }
    st p=head;
    st node=newNode();
    while(p->next){
        p=p->next;
    }
    p->next=node;
    return head;
}
void printStu(st head){
    st p=head;
    while(p){
        printf("%d\t%s\t%d\n",p->id,p->name,p->age);
        p=p->next;
    }
}
void del_agex(st head,int x){
    st p=head;
    if(p->age==x){
        head=p->next;
    }
    while(p->next){
        if(p->next->age==x){
            p->next=p->next->next;
        }
        p=p->next;
    }
    st q=head;
    FILE *fw=fopen("./output.txt","wb");
    if(fw==NULL){
        printf("error");
        exit(1);
    }
    while(q){
        fprintf(fw,"%d\t%s\t%d\n",q->id,q->name,q->age);
        q=q->next;
    }
    fclose(fw);
}
int main(){
    st head=NULL;
    for(int i=0;i<2;i++){
        head=manageStu(head);
    }
    printStu(head);
    del_agex(head,20);
    return 0;
}